<template>
	<view style="padding: 15rpx;">
		<view>
			<view v-for="(parent,index) in dataRes.entQuestionList">
				<radio-group @change="radioChange($event,index)">
					<view class="item_view">{{parent.subject}}</view>
					<view class="uni-list-cell uni-list-cell-pd" v-for="(item, pur) in parent.optionList" :key="pur" v-show="item.option != ''">
						<radio :value="item.score" :checked="parent.score === item.score" color="#016fb8" style="scale: 0.6; font-size: 30rpx;color: #016fb8;"/>
						{{item.option}}
					</view>
				</radio-group>
				<hr>
			</view>
		</view>
		<view class="submit_view">
			<button class="submit" @click="submit">提交</button>
		</view>
	</view>
</template>

<script>
	import env from '../../../utils/env';
	
	import * as exam from '@/api/innovate/envaluation.js'
	
	import * as notice from '@/api/innovate/notice.js'
	
	export default {
		components: {
	
		},
		data() {
			return {
				showMask:false,
				dataRes:[],
				optionList:[],
				scores:[],
				totalScore:0,
			}
		},
		onLoad(option) {
			this.getData()
		},
		methods:{
			getData(){
				notice.getNotice('efb4b99c-d6d8-4f7f-8b06-94f8038578e5').then((res)=>{
					this.dataRes = res.data
					this.optionList = res.entQuestionList
					for (let i = 0; i < this.dataRes.entQuestionList.length; i++) {
					    this.scores[i]= this.dataRes.entQuestionList[i].optionList[0].score
					}
				})
			},
			showTech(){
				uni.navigateTo({
					url:('/subpages/pages/compamyEvaluation/index')
				})
			},
			showTechLittle(){
				uni.navigateTo({
					url:('/subpages/pages/compamyEvaluation/littleEvaluation')
				})
			},
			changeMask(){
				this.showMask = true;
			},
			radioChange: function(e,index) {
				console.log(e.detail.value);
			 this.dataRes.entQuestionList[index].score=e.detail.value
			 console.log(this.dataRes.entQuestionList)
			},
			onClick(index){
				this.index = index
			},
			submit(){
				this.totalScore = 0.0;
				for(let i = 0; i < this.dataRes.entQuestionList.length; i++){
					this.totalScore = parseFloat(this.totalScore) +  parseFloat(this.dataRes.entQuestionList[i].score)
				}
				console.log(this.totalScore)
				if(this.totalScore < 70){
					uni.showModal({
						confirmText:'关闭',
						title:'测评未通过',
						content:'您的得分为：'+this.totalScore,
						showCancel: false,  
					})
				}else{
					uni.showModal({
						confirmText:'确认',
						title:'测评通过',
						content:'您的得分为：'+this.totalScore,
						showCancel: false,  
					})
					exam.exam({
						paperId:'efb4b99c-d6d8-4f7f-8b06-94f8038578e5',
						score:this.totalScore,
						status:'1',
						entExamDetailList:[
							
						],
					})
				}
			}
		}
	}
</script>

<style>
	.item_view{
		font-size: 35rpx;
	}
	
	.maskClass {
		position:fixed;
		bottom:0;
		top:0;
		left:0;
		right:0;
		background-color:rgba(0, 0, 0, 0.5);
		z-index: 2;
	}	
	
	.submit_view {
		height: 90rpx;
		margin: 0 auto;
	}
		
	.submit_view .submit{
		background-color: #016fb8;
		height: 90rpx;
		width: 95%;
		font-size: 35rpx;
		margin: 0 auto;
		color: white;
	}
</style>